package com.own.business.question.entity.dto;

import com.own.business.question.entity.bo.QuestionOptionBo;
import com.own.component.common.base.entity.BaseDto;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * QuestionOptionDto
 *
 * @author chenxueli
 * @date 2021/05/14 09:41:05
 */
@Schema(description = "题目选项" + ConstantBeanSuffix.DTO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class QuestionOptionDto extends BaseDto<QuestionOptionBo> {

    @Schema(description = "题目id")
    private Long questionId;

    @Schema(description = "文字内容")
    private String content;

    @Schema(description = "图片文件id")
    private String image;

    @Schema(description = "选择题的时候是否为正确的答案 1-是 0不是")
    private Integer isAnswer;

    /**
     * 转业务层对象
     *
     * @param entity 原业务层对象
     * @return 业务层对象
     */
    @Override
    public QuestionOptionBo toBo(QuestionOptionBo entity) {
        if (entity == null) {
            entity = new QuestionOptionBo();
        }
        entity.setQuestionId(questionId);
        entity.setContent(content);
        entity.setImage(image);
        entity.setIsAnswer(isAnswer);
        return super.toBo(entity);
    }

}
